module utils {
	export class InputScrollTool {

		private static _instance: utils.InputScrollTool;
		private hasResizeEvent: boolean = false;

		public constructor() {

		}

		public static get instance(): utils.InputScrollTool {
			if (!utils.InputScrollTool._instance) {
				this._instance = new utils.InputScrollTool();
			}
			return this._instance;
		}

		public addResizeEvent(): void {
			if (this.hasResizeEvent) return;
			window.addEventListener('resize', this.scrollIntoViewIfNeeded);
			this.hasResizeEvent=true;
		}

		private scrollIntoViewIfNeeded() {
			if (document.activeElement.tagName != 'INPUT') return;
			if (!document.activeElement["scrollIntoViewIfNeeded"]) return;
			document.activeElement['scrollIntoViewIfNeeded']();
			window.removeEventListener('resize', this.scrollIntoViewIfNeeded);
			this.hasResizeEvent=false;
		}
	}
}